// JavaScript Document

Vsg.FsoFile = Class.create();


// defined construt
Vsg.FsoFile.prototype.initialize = function() {
	var file = null;

	if (typeof(arguments[0]) == "undefined") {
		alert("没有指定对应组件!");
	}
	if (typeof(arguments[0]) == "string") {
		file = arguments[0];
	}
		
	function openFileHandle() {
		var fso = null;
		try {
			fso = new ActiveXObject("Scripting.FileSystemObject");
		} catch (ex) {
			alert(ex);
			alert("读写本地文件控件不能执行！建议加本站为可信站点，或联系管理人员！");
		}
		return fso;
	}
	
	/**
	 * get the file name
	 */
	this.getFileName = function() {
		var filename = null;
		var fso = openFileHandle();
		if (fso.FileExists(file)) {
			filename = fso.GetFileName(file);
		} else {
			alert("文件不存在: [" + file+"].");
		}
		return filename;
	}		

	/**
	 * get the file handle Object
	 */
	this.getFile  = function() {
		var fso = openFileHandle();
		var f = fso.GetFile(file);
		return f;
	}

	this.del = function() {
		var fso = openFileHandle();
		if (fso.FileExists(file)) {
			fso.DeleteFile(file);
		} else {
			alert("文件不存在: [" + file+"].");
		}
	}
	
	
	this.copyFile = function($destFile) {
		var fso = openFileHandle();
		fso.copyFile(file,$destFile);
		fso = null;
	}
	
	this.moveToFile = function($destFile) {
		var fso = openFileHandle();
		fso.moveFile(file,$destFile);
		fso = null;
	}

	
}